import request from '@/config/axios'

// 车间信息 VO
export interface BaseWorkShopVO {
  id: string // 车间ID
  workShopCode: string // 车间编码
  workShopName: string // 车间名称
  workShopUse: string // 车间用途
  note: string // 备注信息
  orderNo:number,
  status: boolean, // 车间状态
  plcId:string
}

// 生产区域信息 VO
export interface BaseMachineAreaVO {
  id: string // 生产区域ID
  machineAreaCode: string // 生产区域编码
  machineArea: string // 生产区域名称
  workShopId: string // 所属车间ID
  machineAreaUse: string // 生产区域用途
  note: string // 备注信息
  status: boolean // 生产区域状态
  orderNo: number // 显示顺序
  plcId:string
}

// 机台产线基础信息 VO
export interface BaseMachineInfoVO {
  id: string // 机台信息ID
  machineAreaCode: string // 机台区域代码
  machineArea: string // 机台区域
  machineName: string // 机台名称
  machineCode: string // 机台代码
  machineProperty: string // 机台参数
  machineBrand: string // 机台品牌
  machinePlcId: string // PLC编号
  projectId: string // 项目编号
  regionId: string // 区域编号
  hasWeight: boolean // 是否有电子秤
  weightNum: number // 电子秤数量
  isScheduling: boolean // 是否用于人力排班
  isMachine: boolean // 是否是机台
  orderNo: number // 显示顺序
  workShopId: string // 车间ID
  machineAreaId: string // 区域ID
}


// 车间信息 API
export const BaseWorkShopApi = {

  // 查询车间（精简)列表
  getSimpleWorkShopList: async (): Promise<BaseWorkShopVO[]> => {
    return await request.get({ url: '/mes/base-work-shop/simple-list-work-shop' })
  },
  // 查询车间信息分页
  getBaseWorkShopPage: async (params: any) => {
    return await request.get({ url: `/mes/base-work-shop/page`, params })
  },

  // 查询车间信息详情
  getBaseWorkShop: async (id: number) => {
    return await request.get({ url: `/mes/base-work-shop/get?id=` + id })
  },

  // 新增车间信息
  createBaseWorkShop: async (data: BaseWorkShopVO) => {
    return await request.post({ url: `/mes/base-work-shop/create`, data })
  },

  // 修改车间信息
  updateBaseWorkShop: async (data: BaseWorkShopVO) => {
    return await request.put({ url: `/mes/base-work-shop/update`, data })
  },

  // 删除车间信息
  deleteBaseWorkShop: async (id: number) => {
    return await request.delete({ url: `/mes/base-work-shop/delete?id=` + id })
  },

  // 导出车间信息 Excel
  exportBaseWorkShop: async (params) => {
    return await request.download({ url: `/mes/base-work-shop/export-excel`, params })
  },


// ==================== 子表（生产区域信息） ====================
  // 查询区域（精简)列表
  getSimpleMachineAreaList: async (): Promise<BaseMachineAreaVO[]> => {
    return await request.get({ url: '/mes/base-work-shop/base-machine-area/simple-list-machine-area'})
  },
  // 获得生产区域信息分页
  getBaseMachineAreaPage: async (params) => {
    return await request.get({ url: `/mes/base-work-shop/base-machine-area/page`, params })
  },
  // 新增生产区域信息
  createBaseMachineArea: async (data) => {
    return await request.post({ url: `/mes/base-work-shop/base-machine-area/create`, data })
  },

  // 修改生产区域信息
  updateBaseMachineArea: async (data) => {
    return await request.put({ url: `/mes/base-work-shop/base-machine-area/update`, data })
  },

  // 删除生产区域信息
  deleteBaseMachineArea: async (id: number) => {
    return await request.delete({ url: `/mes/base-work-shop/base-machine-area/delete?id=` + id })
  },

  // 获得生产区域信息
  getBaseMachineArea: async (id: number) => {
    return await request.get({ url: `/mes/base-work-shop/base-machine-area/get?id=` + id })
  },

// ==================== 子表（机台产线基础信息） ====================

  // 获得机台产线基础信息分页
  getBaseMachineInfoPage: async (params) => {
    return await request.get({ url: `/mes/base-work-shop/base-machine-info/page`, params })
  },
  // 新增机台产线基础信息
  createBaseMachineInfo: async (data) => {
    return await request.post({ url: `/mes/base-work-shop/base-machine-info/create`, data })
  },

  // 修改机台产线基础信息
  updateBaseMachineInfo: async (data) => {
    return await request.put({ url: `/mes/base-work-shop/base-machine-info/update`, data })
  },

  // 删除机台产线基础信息
  deleteBaseMachineInfo: async (id: number) => {
    return await request.delete({ url: `/mes/base-work-shop/base-machine-info/delete?id=` + id })
  },

  // 获得机台产线基础信息
  getBaseMachineInfo: async (id: number) => {
    return await request.get({ url: `/mes/base-work-shop/base-machine-info/get?id=` + id })
  },

}
